import { mapGetters } from 'vuex'

export default {
  computed: {
    ...mapGetters([
      'userInfo'
    ]),
    userPermissionList() {
      return this.userInfo.permissionList
    },
    checkPermission(permissionCode) {
      return this.permissionCheck(permissionCode)
    },
    // 修改机构信息权限
    updateOrganizationPermission() {
      return this.permissionCheck('01080102')
    },
    // 添加员工权限
    addStaffPermission() {
      return this.permissionCheck('010701')
    },
    // 修改员工权限
    editStaffPermission() {
      return this.permissionCheck('010702')
    },
    // 查看员工详情
    viewStaffPermission() {
      return this.permissionCheck('010703')
    },
    // 员工权限设置
    staffPermissionSettingPermission() {
      return this.permissionCheck('010704')
    },
    // 预审核
    preAuditPermission() {
      return this.permissionCheck('03010401')
    },
    // 审核
    auditPermission() {
      return this.permissionCheck('03010402')
    },
    // 复审
    finalAuditPermission() {
      return this.permissionCheck('03010403')
    },
    // 改变供应状态
    changeSupplyStatePermission() {
      return this.permissionCheck('03010404')
    },
    // 添加商品类别
    addGoodsCategoryPermission() {
      return this.permissionCheck('010201')
    },
    // 修改商品类别
    editGoodsCategoryPermission() {
      return this.permissionCheck('010202')
    },
    // 添加采购单
    addPurchaseOrderPermission() {
      return this.permissionCheck('05020301')
    },
    // 修改采购单
    editPurchaseOrderPermission() {
      return this.permissionCheck('05020302')
    },
    // 查看采购单
    viewPurchaseOrderPermission() {
      return this.permissionCheck('05020302')
    },
    // 采购收货单
    stockManagementBillPurchaseReceiptIndex() {
      return this.permissionCheck('050204')
    },
    // 预审核采购单
    preAuditPurchaseOrderPermission() {
      return this.permissionCheck('05020303')
    },
    // 审核采购单
    auditPurchaseOrderPermission() {
      return this.permissionCheck('05020304')
    },
    // 添加无订单采购
    addPurchaseReceiptPermission() {
      return this.permissionCheck('05020401')
    },
    // 批量一审机构补货单
    batchFirstAuditPurchaseOrderPermission() {
      return this.permissionCheck('02020102')
    },
    // 批量二审机构补货单
    batchSecondAuditPurchaseOrderPermission() {
      return this.permissionCheck('02020103')
    },
    // 批量三审机构补货单
    batchFinalAuditPurchaseOrderPermission() {
      return this.permissionCheck('02020108')
    },
    // 批量机构补货单接单
    batchReceivePurchaseOrderPermission() {
      return this.permissionCheck('02020104')
    },
    // 批量机构补货单撤单
    batchCancelPurchaseOrderPermission() {
      return this.permissionCheck('02020105')
    },
    // 查看机构补货单
    viewOrganizationPurchaseOrderPermission() {
      return this.permissionCheck('02020106')
    },
    // 修改供应商品信息
    basicArchivesProductInformationISupplyEdit() {
      return this.permissionCheck('010903')
    },
    // 添加供应商
    addSupplyEditPermission() {
      return this.permissionCheck('03010101')
    },
    // 修改供应
    editSupplyEditPermission() {
      return this.permissionCheck('03010102')
    },
    // 查看供应商
    viewSupplyEditPermission() {
      return this.permissionCheck('03010103')
    },
    // 采购补货单打印
    purchaseOrderPrinting() {
      return this.permissionCheck('02020107')
    },
    // 无人销售监控台
    unmannedSalesWorkbenchPermission() {
      return this.permissionCheck('1401')
    }
  },
  methods: {
    permissionCheck(permissionCode) {
      const index = this.userPermissionList.findIndex(res => res.permissionCode === permissionCode)
      return index >= 0
    }
  }
}
